﻿
@page "/Wms/BuyInWarehouseDetail/Create"
@using nERP.ViewModel.Wms.BuyInWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
  <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit" >
    <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
      <BootstrapInput @bind-Value="@Model.Entity.Seq"/>
      <Select @bind-Value="@Model.Entity.BuyInWarehouseId" Items="AllBuyInWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g934922057025477798e9dc0a375a6e79"/>
      <BootstrapInput @bind-Value="@Model.Entity.BuyInWarehouseDetailCode"/>
      <Select @bind-Value="@Model.Entity.WarehouseId" Items="AllWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g730d4bf181a7415a917f499bc7359979"/>
      <Select @bind-Value="@Model.Entity.BuyId" Items="AllBuys" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g23152d2b01e1456fa51e9d05fceb97b1"/>
      <Select @bind-Value="@Model.Entity.BuyDetailId" Items="AllBuyDetails" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g764599a82b3b43a1abe58bdef1d494e4"/>
      <Select @bind-Value="@Model.Entity.GoodsId" Items="AllGoodss" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g23b7c10194634bf0a95a1aa98a08fad6"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsName"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsSpec"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsUnit"/>
      <BootstrapInput @bind-Value="@Model.Entity.BuyInNumber"/>
      <BootstrapInput @bind-Value="@Model.Entity.Remark"/>
    </Row>

    <div class="modal-footer table-modal-footer">
      <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
      <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
    </div>

  </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private BuyInWarehouseDetailVM Model = new BuyInWarehouseDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {
                        
        
        await PostsForm(vform, "/api/Wms/BuyInWarehouseDetail/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllBuyInWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllBuys = new List<SelectedItem>();
    private List<SelectedItem> AllBuyDetails = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllBuyInWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetBuyInWarehouses");
        AllBuyInWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuys = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetBuys");
        AllBuys.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuyDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetBuyDetails");
        AllBuyDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
